package com.konne.nightmare.FastPublicOpinion.mvp.model.impl;


import com.konne.nightmare.FastPublicOpinion.base.OnLoadDataListener;
import com.konne.nightmare.FastPublicOpinion.bean.EventBean;
import com.konne.nightmare.FastPublicOpinion.bean.LoginBean;
import com.konne.nightmare.FastPublicOpinion.http.BaseObserver;
import com.konne.nightmare.FastPublicOpinion.http.BaseResponse;
import com.konne.nightmare.FastPublicOpinion.http.RetrofitFactory;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IEventFragmentModel;
import com.konne.nightmare.FastPublicOpinion.mvp.model.IHomeFragmentModel;

import org.json.JSONObject;

import java.util.List;


public class EventFragmentModelImpl implements IEventFragmentModel {
    @Override
    public void selectEventPlanList(JSONObject requestBody, OnLoadDataListener<List<EventBean.RowsBean>> onLoadDataListener) {
            RetrofitFactory.getInstance().selectEventPlanList(requestBody, new BaseObserver<List<EventBean.RowsBean>>() {
                @Override
                protected void onSuccess(BaseResponse<List<EventBean.RowsBean>> t) throws Exception {
                    onLoadDataListener.onSuccess(t);
                }

                @Override
                protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                    onLoadDataListener.onFailure(error);
                }
            });
    }

    @Override
    public void updateEventPlan(JSONObject requestBody, OnLoadDataListener<String> onLoadDataListener) {
        RetrofitFactory.getInstance().updateEventPlan(requestBody, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }
    @Override
    public void delete(JSONObject jsonObject, OnLoadDataListener<String> onLoadDataListener) {

        RetrofitFactory.getInstance().delete(jsonObject, new BaseObserver<String>() {
            @Override
            protected void onSuccess(BaseResponse<String> t) throws Exception {
                onLoadDataListener.onSuccess(t);
            }

            @Override
            protected void onFailure(String error, boolean isNetWorkError) throws Exception {
                onLoadDataListener.onFailure(error);
            }
        });
    }
}
